package com.yyge.service.impl;

import com.yyge.entity.OrderGoods;
import com.yyge.mapper.OrderGoodsMapper;
import com.yyge.service.OrderGoodsService;
import com.yyge.vo.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class OrderGoodsServiceImpl implements OrderGoodsService {
        private static Logger logger = LoggerFactory.getLogger(AdminServiceImpl.class);
        private OrderGoodsMapper orderGoodsMapper = null;
   @Override
    public R insert(OrderGoods orderGoods) {

        // 调用数据访问层
        int insert=orderGoodsMapper.insert(orderGoods);
        logger.debug("数据访问层执行新增方法完成，数据库返回受影响的行数为：" + insert);
        R r=new R();
        if(insert>0){
          r.setCode(200);
          r.setMessage("新增成功！");
          logger.debug("返回新增userInfo成功");
         }else{
          r.setCode(-1);
          r.setMessage("新增失败!");
          logger.debug("返回新增userInfo失败");
        }
        return r;
    }

    @Override
    public R deleteByPrimaryKey(Integer key) {
        int deleteByPrimaryKey=orderGoodsMapper.deleteByPrimaryKey(key);
        R r=new R();
        if(deleteByPrimaryKey>0){
            r.setCode(200);
            r.setMessage("删除成功！");
        }else{
            r.setCode(-1);
            r.setMessage("删除失败！");
        }
        return r;
    }

    @Override
    public R updateByPrimaryKey(OrderGoods orderGoods) {
        int undate=orderGoodsMapper.updateByPrimaryKey(orderGoods);
        R r=new R();
        if(undate>0){
            r.setCode(200);
            r.setMessage("修改成功！");
        }else{
            r.setCode(-1);
            r.setMessage("修改失败！");
        }
        return r;
    }

    @Override
    public R selectByPrimaryKey(Integer key) {
        OrderGoods addrInfo=orderGoodsMapper.selectByPrimaryKey(key);
        R r=new R();
        r.setData(addrInfo);
        return r;
    }
}
